package com.httpDemo.listener;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

/**
 * web三大组件之一：Listener监听器
 * ServletContext的监听器：ServletContextListener和ServletContextAttributeListener
 * HttpSession的监听器：HttpSessionListener和HttpSessionAttributeListener
 * ServletRequet的监听器：ServletRequestListener和ServletRequestAttributeListener
 * 
 * @author 86173
 *
 */
public class MyListener implements ServletContextListener {

	/**
	 * 初始化
	 */
	@Override
	public void contextInitialized(ServletContextEvent sce) {
		ServletContext context = sce.getServletContext();
		context.setAttribute("ctx", context.getContextPath());
		System.out.println("----------contextInitialized---------");
	}

	/**
	 * 销毁
	 */
	@Override
	public void contextDestroyed(ServletContextEvent sce) {
		// TODO Auto-generated method stub
		ServletContextListener.super.contextDestroyed(sce);
	}
}
